<?php include show_tpl('public_uheader.htm'); ?>

<div style="width:100%; height:20px; background:#E9ECF3;"></div>

<?php include show_tpl('public_usider.htm'); ?>

<div id="page-wrapper" class="gray-bg">

	<div class="row wrapper wrapper-content">
		<div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="panel-title">
							<em class="fa fa-list"></em>
                             交易订单&nbsp;&nbsp;
							<span style="margin-top:-20px;margin-bottom:20px;text-align:center;font-size:12px;color:#666">
								提交订单数：<span class="blue"><?php echo $tongji_total['count']; ?></span>&nbsp;&nbsp;&nbsp;
								订单总金额：<span class="blue">¥<?php echo round($tongji_total['total'],2); ?></span>&nbsp;&nbsp;&nbsp;
								已付订单数：<span class="green"><?php echo $tongji_paid['count']; ?></span>&nbsp;&nbsp;&nbsp;
								订单总金额：<span class="green">¥<?php echo round($tongji_paid['total'],2); ?></span>&nbsp;&nbsp;&nbsp;
								实付总金额:<span class="green">¥<?php echo round($tongji_total['coin_merchant_total'],3); ?></span>&nbsp;&nbsp;&nbsp;
								未付订单数：<span class="red"><?php echo $tongji_total['count']-$tongji_paid['count']; ?></span>&nbsp;&nbsp;&nbsp;
								未付总金额：<span class="red">¥<?php echo $tongji_total['total']-$tongji_paid['total']; ?></span>
							</span>
						</div>
                    </div>
					<div class="panel-body">
						<form method="get" class="form-inline m-b-xs" action="<?php echo url('user-order');?>">
							<div class="form-group">
								<select name="status" class="form-control">
									<option value="-1">全部</option>
									<option value="0" <?php if($status==0){echo 'selected';} ?>>未付款</option>
									<option value="1" <?php if($status==1){echo 'selected';} ?>>已付款</option>
								</select>
							</div>&nbsp;&nbsp;
							<?php if($daili==1){?>
							<div class="form-group">
								<select class="form-control" name="son_id">
									<option value="0">全部用户</option>
									<?php
									if(!empty($sonarr)){
									foreach($sonarr as $c){ ?>
									<option value="<?php echo $c['uid'];?>" <?php if($son_id==$c['uid']){echo 'selected';} ?>><?php echo $c['username'];?></option>
									<?php }
									}
									?>
								</select>
							</div>
							<?php }?>&nbsp;&nbsp;

							<div class="form-group">
								<select class="form-control" name="channel">
									<option value="0">全部通道</option>
									<?php
									if(!empty($channels)){
									foreach($channels as $c){ ?>
									<option value="<?php echo $c['id'];?>" <?php if($channel==$c['id']){echo 'selected';} ?>><?php echo $c['name'];?></option>
                                    <?php }} ?>
                                </select>
							</div>&nbsp;&nbsp;

							<div class="form-group">
								<input type="text" class="form-control" name="merchant" placeholder="商户订单号" value="<?php echo $merchant?>" size="15">
							</div>&nbsp;&nbsp;
							<div class="form-group">
								<input type="text" class="form-control" name="plat" placeholder="平台订单号" value="<?php echo $plat;?>" size="14">
							</div>&nbsp;&nbsp;
							<?php if($user['is_proxy']==1){ ?>
							<div class="form-group">
								<input type="text" class="form-control" name="merchant_username" placeholder="商户帐号" value="<?php echo $merchant_username;?>" size="15">
							</div>&nbsp;&nbsp;
							<?php } ?>
							<div class="form-group">
								<div class="input-group">
									<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
									<input type="text" name="fdate" class="form_datetime form-control" value="<?php echo $fdate;?>">
									<span class="input-group-addon">至</span>
									<input type="text" name="tdate" class="form_datetime form-control" value="<?php echo $tdate;?>">
								</div>
							</div>&nbsp;&nbsp;
							<button type="submit" class="btn btn-primary">
								<i class="fa fa-search"></i>
								&nbsp;立即查询
							</button>
							<a class="btn btn-info" href="<?php echo url('user-order').$param.'&export=1';?>">导出EXCEL</a>
						</form>
						<div class="table-responsive">
							<table class="table table-bordered">
								<thead>
									<tr>
										<th>订单时间</th>
										<?php if($user['is_proxy']==1){ ?>
										<th>商户帐号</th>
										<?php } ?>
										<th>商户订单号</th>
										<th>平台订单号</th>
										<th>订单金额</th>
										<th>实付金额</th>
										<th>收入金额</th>
										<th>收款道名称</th>
										<th>订单状态</th>
										<th>通知状态</th>
									</tr>
								</thead>
								<tbody>
									<?php
									 if(!empty($log)){
									 foreach($log as $l){ ?>
									<tr>
										<td class="text-center"><?php echo date('Y-m-d H:i:s', $l['time']);?></td>
										<?php if($user['is_proxy']==1){ ?>
										<td class="text-center"><?php echo $l['username'];?></td>
										<?php } ?>
										<td class="text-center"><?php echo $l['order_merchant'];?></td>
										<td class="text-center"><?php echo $l['order_plat'];?></td>
										<td class="text-center"><?php echo $l['coin'];?></td>
										<td class="text-center"><?php echo $l['coin_pay'];?></td>
										<td class="text-center"><?php echo $l['coin_merchant'];?></td>
										<td class="text-center"><?php echo $l['channel'];?></td>
										<td class="text-center"><?php echo $l['status']==0?'未支付':'<span style="color:#27ae60;">已支付</span>';?></td>
										<td class="text-center">

											<?php echo $l['notice_status']==0?'未通知':'<span style="color:#27ae60;">已通知</span>';?>
											<?php if($l['status']){ ?>
											<a style="color: #00a2d4;cursor:pointer" class="notice" data-id="<?php echo $l['id'] ?>" >重新通知  </a>
											<?php }  ?>
										</td>
									</tr>
									<?php }} ?>
								</tbody>
							</table>
						</div>


						<ul class="text-center"><?php echo $pagination; ?></ul>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<?php include show_tpl('public_ufooter.htm'); ?>

<script>
    var layer;
    layui.use(['layer', 'form'], function(){
        layer = layui.layer
            ,form = layui.form;

    });

//日期插件
$(".form_datetime").datetimepicker({
	language:  'zh',
	format: 'yyyy-mm-dd hh:ii:ss',//显示格式
	todayHighlight: 1,//今天高亮
	minView: 'hour',//设置只显示到月份
	startView: 'month',
	forceParse: 0,
	autoclose: 1//选择后自动关闭
});
$('.notice').click(function () {

	var id = $(this).data('id');
	var url ="<?php echo url('user-notice') ;?>"
	$.post(url,{id:id},function (data) {
	    console.log(data);
        if (data.code) {
            layer.msg(data.msg,{time:2000,icon:1})
        }else {
            layer.msg(data.msg,{time:2000,icon:2})
		}
    },'json')
})

</script>